package fr.ensma.ia.miniblog.sbeans;

import fr.ensma.ia.miniblog.persistence.Categorie;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author LeBlero
 */
@Stateless
public class CategorieBean implements ICategorieLocal {

    @PersistenceContext(unitName="MiniBlog_PUnit")
    private EntityManager em;

    @Override
    public Categorie createCategorie(Categorie c) {
        em.persist(c);
        return c;
    }

    @Override
    public Categorie getCategorieById(Long id) {
        return em.find(Categorie.class, id);
    }

    @Override
    public void deleteCategorie(Categorie c) {
        Categorie cat = em.merge(c);
        em.remove(cat);
    }

}
